package com.myzl.coal.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.myzl.coal.domain.AgreementContrast;
import com.myzl.coal.mapper.AgreementContrastMapper;
import com.myzl.coal.service.IAgreementContrastService;
import com.myzl.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 协议对照Service业务层处理
 *
 * @author myzl
 * @date 2022-07-20
 */
@Service
public class AgreementContrastServiceImpl extends ServiceImpl<AgreementContrastMapper, AgreementContrast> implements IAgreementContrastService
{
    @Autowired
    private AgreementContrastMapper agreementContrastMapper;

    /**
     * 查询协议对照
     *
     * @param id 协议对照主键
     * @return 协议对照
     */
    @Override
    public AgreementContrast selectAgreementContrastById(Long id)
    {
        return agreementContrastMapper.selectAgreementContrastById(id);
    }

    /**
     * 查询协议对照列表
     *
     * @param agreementContrast 协议对照
     * @return 协议对照
     */
    @Override
    public List<AgreementContrast> selectAgreementContrastList(AgreementContrast agreementContrast)
    {
        return agreementContrastMapper.selectAgreementContrastList(agreementContrast);
    }

    /**
     * 新增协议对照
     *
     * @param agreementContrast 协议对照
     * @return 结果
     */
    @Override
    public int insertAgreementContrast(AgreementContrast agreementContrast)
    {
        agreementContrast.setCreateTime(DateUtils.getNowDate());
        return agreementContrastMapper.insertAgreementContrast(agreementContrast);
    }

    /**
     * 修改协议对照
     *
     * @param agreementContrast 协议对照
     * @return 结果
     */
    @Override
    public int updateAgreementContrast(AgreementContrast agreementContrast)
    {
        agreementContrast.setUpdateTime(DateUtils.getNowDate());
        return agreementContrastMapper.updateAgreementContrast(agreementContrast);
    }

    /**
     * 批量删除协议对照
     *
     * @param ids 需要删除的协议对照主键
     * @return 结果
     */
    @Override
    public int deleteAgreementContrastByIds(Long[] ids)
    {
        return agreementContrastMapper.deleteAgreementContrastByIds(ids);
    }

    /**
     * 删除协议对照信息
     *
     * @param id 协议对照主键
     * @return 结果
     */
    @Override
    public int deleteAgreementContrastById(Long id)
    {
        return agreementContrastMapper.deleteAgreementContrastById(id);
    }

    @Override
    public List<AgreementContrast> getListSortAddress() {
        LambdaQueryWrapper<AgreementContrast> lambdaQueryWrapper = new LambdaQueryWrapper<AgreementContrast>();
        lambdaQueryWrapper.orderByAsc(AgreementContrast::getAddress);
        List<AgreementContrast> list = list(lambdaQueryWrapper);
        return list;
    }
}
